From 68b6e40d2110b5f1551899eb48db909022b432be Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Fri, 28 Jan 2005 16:34:08 +0000 Subject: [PATCH] bitkeeper revision 1.1159.212.52 (41fa6980PfhDt-hKCfacnyHcFB7DNQ) Make page allocator 64-bit safe. Signed-off-by: keir.fraser@cl.cam.ac.uk --- xen/arch/x86/memory.c | 11 ++++++++--- xen/common/page_alloc.c | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/memory.c b/xen/arch/x86/memory.c index 69bca437d9..cfc37e84aa 100644 --- a/xen/arch/x86/memory.c +++ b/xen/arch/x86/memory.c @@ -148,13 +148,18 @@ unsigned long max_page; void __init init_frametable(void) { -#ifdef __i386__ +#if defined(__i386__) unsigned long i, p; +#endif - frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START; frame_table_size = max_page * sizeof(struct pfn_info); frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK; +#if defined(__x86_64__) + frame_table = __va(alloc_boot_pages(frame_table_size, 4UL << 20)); +#elif defined(__i386__) + frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START; + for ( i = 0; i < frame_table_size; i += (4UL << 20) ) { p = alloc_boot_pages(min(frame_table_size - i, 4UL << 20), 4UL << 20); @@ -163,9 +168,9 @@ void __init init_frametable(void) idle_pg_table[(FRAMETABLE_VIRT_START + i) >> L2_PAGETABLE_SHIFT] = mk_l2_pgentry(p | __PAGE_HYPERVISOR | _PAGE_PSE); } +#endif memset(frame_table, 0, frame_table_size); -#endif } void arch_init_memory(void) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 09674a38f1..eae1692eb1 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -49,8 +49,9 @@ static unsigned long bitmap_size; /* in bytes */ static unsigned long *alloc_bitmap; #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8) -#define allocated_in_map(_pn) \ -(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1<<((_pn)&(PAGES_PER_MAPWORD-1)))) +#define allocated_in_map(_pn) \ +( !! (alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & \ + (1UL<<((_pn)&(PAGES_PER_MAPWORD-1)))) ) /* * Hint regarding bitwise arithmetic in map_{alloc,free}: @@ -79,13 +80,13 @@ static void map_alloc(unsigned long first_page, unsigned long nr_pages) if ( curr_idx == end_idx ) { - alloc_bitmap[curr_idx] |= ((1<